-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to not generate precise GC info #75817
Conversation
Follow up to dotnet#75803. If enabled, conservative GC stack scanning will be used and metadata related to GC stack reporting will not be generated. The generated executable file will be smaller, but the GC will be less efficient (garbage collection might take longer and keep objects alive for longer periods of time than usual). Saves 4.4% in size on a Hello World. I'll take that.
Some libraries tests are guarded with IsPreciseGcSupported which is currently implemented as "Not mono" - perhaps, worth adding this mode here for NativeAOT? |
Interesting. This could be a useful option for platforms that do not fully support stack walking.
I am curious at %% savings for larger apps. Assuming that there is fixed native runtime size, larger apps may benefit a bit more. |
CoreCLR is also capable of running in this mode. It might be worth it if we're adding official testing for this. It's not what I'm doing right now. (I don't know if there's a good way to probe for this.)
It will be once this merges - about 15% of hello world (500 kB of 3.6 MB) is native code that isn't affected by this. This percentage will be smaller for larger apps. But 15% is already a pretty small number. |
For the testing purposes, since you want to enable this and do a test pass, you could just set it to true temporarily - to reduce noise. |
It is not a lot of noise though typically. False positives when doing conservative stack scans are relatively rare. |
It was pretty annoying when Mono was wired up to run libs tests 🙂 |
It does not need to be frequent for a failure to become annoying. :-) Statistically though stacks are shallow and in a big(ish) program most objects would be rooted by statics and/or a few long-lived stack roots that hold large portions of the app context. Conservative scanning is a bigger problem when both stack and heap are conservative. When it is just stacks, there are fewer opportunities. |
Cool. I was surprised we can just not generate it and GC.Collect works. It's probably only GC.Collect that works. Will probably have to leave a breadcrumb somewhere for the runtime not to expect it. |
Do we need GC info for exception handling? |
We have done some measurements around this some years back. The average perf hit for real world server (compute bound) apps is about 20% rps.
CoreCLR is not reliable (ie will crash intermittently) with conservative stack scanning. Dynamic methods and collectible assemblies are not able to handle situation when unreachable object becomes reachable again. |
It would be interesting to do similar comparison with NativeAOT if we have a good benchmark Compared with CoreCLR there are two differences:
It is hard to tell how much the effect the differences make. The second is probably insignificant, but there is a chance the first has measurable impact. The place where CoreCLR turns off async suspension: runtime/src/coreclr/vm/threadsuspend.cpp Line 4852 in 774324e
|
Actually |
The crash is happening here: runtime/src/coreclr/nativeaot/Runtime/windows/CoffNativeCodeManager.cpp Lines 561 to 574 in 16cb35f
So we need GC info to unwind reverse P/invokes. Looks like we would need to generate some sort of minimal GC info to allow for that. (There might be more - it's just the crash that I looked at.) I'm going to close this. It was only worth it if it's reasonably cheap since it would likely stay an obscure undocumented switch anyway. |
Yeah, GC info conveys some non-GC info, so you can't skip emitting it entirely. |
Follow up to #75803.
If enabled, conservative GC stack scanning will be used and metadata related to GC stack reporting will not be generated. The generated executable file will be smaller, but the GC will be less efficient (garbage collection might take longer and keep objects alive for longer periods of time than usual).
Saves 4.4% in size on a Hello World. I'll take that.
Cc @dotnet/ilc-contrib